<g:setProvider library="jquery"/>

    <script type="text/javascript">
    	$('#loginDialog').dialog('option', 'buttons', { 
        		"Login": function() { $('#sergi').click(); }, 
    	   		"Cancel": function() {
                    $(this).dialog("close");
                }
		});

		function submitForm(){
			$('#submitForm').submit();
		}
    </script>

<div id="sergiDiv">
	<g:if test="${session.userLogged != null}">
	    <script type="text/javascript">submitForm();</script>
	</g:if>
	
	
	<g:if test="${flash.message}">
	    <div class="message">${flash.message}</div>
	</g:if>

<g:formRemote id="loginFormModal" name="loginFormModal" update="sergiDiv" url="[controller:'autentication',action:'login']">
    <div class="dialog">
        <table>
            <tbody>
                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="name">Usuari:</label>
                    </td>
                    <td valign="top">
                        <input type="text" id="usuari" name="usuari"/>
                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="description">Contrasenya:</label>
                    </td>
                    <td valign="top">
                        <g:passwordField id="contrasenya" name="contrasenya"/>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
    <input class="save" type="submit" id="sergi" value="Create" style="display:none"/>
</g:formRemote>
</div>

<form method="post" action="/dyd/principal/list" id="submitForm" name="submitForm"></form>